home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-01-12 | 1.8 KB | 76 lines | [TEXT/GEOL] |
- Item 1071028 11-Jan-90 13:28
-
- From: J.HARVEY Harvey, John
-
- To: D5369 Mgmt Sys Des, Chuck McMath,PRT
-
- cc: MACAPP.TECH$ MacApp Technical
-
- Sub: cmd-period
-
- Chuck,
-
- The code below will do the right think international wise as far as checking
- for a command period. You need to strip out the command key to check and see
- if a period was pressed since command hides the fact that a period was pressed
- on systems where shift-somekey is necessary to produce a period (italian for
- one).
-
- John Harvey
- MacDTS
-
- CONST
- kMaskModifier = 0xFE00; {need to stript command key from Modifiers}
- kMaskVirtualKey = 0x0000FF00; {get virtual key from event message}
- kMaskASCII1 = 0x000000FF; {get key from KeyTrans return}
- kPeriod = ORD('.');
-
- TYPE
- EventPtr = ^EventRecord;
-
- FUNCTION CmdPeriod(theEvent: EventPtr): Boolean;
- VAR
- keyCode : Integer;
- virtualKey,
- keyInfo,
- theChar,
- state,
- keyCId : Longint;
- hKCHR : Handle;
-
- BEGIN
-
- CmdPeriod := FALSE;
-
- IF ( theEvent^.what = keyDown || theEvent^.what = autoKey) THEN BEGIN
-
- {see if the command key is down. If it is, get the ASCII }
-
- IF ( BAND(theEvent^.modifiers,cmdKey) <> 0 ) THEN BEGIN
-
- virtualKey := BAND(theEvent^.message,kMaskVirtualKey) DIV 256;
- keyCode := BAND(theEvent^.modifiers,kMaskModifiers) + virtualKey+btnState;
- state := 0;
-
- keyCId := GetScript( GetEnvirons(smKeyScript), smScriptKeys);
-
- {read the appropriate KCHR resource }
- hKCHR := GetResource('KCHR',keyCId);
-
- IF (hKCHR <> NIL) THEN BEGIN
- HLock(hKCHR);
- keyInfo := KeyTrans(hKCHR^,keyCode,state);
- HUnlock(hKCHR);
- ReleaseResource(hKCHR);
-
- theChar := BAND(keyInfo,kMaskASCII1);
-
- IF ( theChar = kPeriod)
- CmdPeriod := TRUE;
- END;
- END;
- END;
-
- END;
-
-